/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.pw.elka.gtsna.centrality.betweenness;

import edu.pw.elka.gtsna.graph.Graph;

/**
 *
 * @author szczepan
 */
public class SVNodeBetweenness  extends NodeBetweennessCentrality {
    
    
	public SVNodeBetweenness(Graph graph){
		super(graph);
	}
	
    @Override
    void accumulation(int source) {
 //   	System.out.println("************  "+source+"  *******************"); 
        while (!stack.isEmpty()){
        	Integer w = stack.pop();
            for(Integer v: pred.get(w)){
                delta.put(v, delta.get(v) +  (sigma.get(v).doubleValue()/sigma.get(w).doubleValue())*( (1.0/dist.get(w)) + delta.get(w)) );
//             	if (v==1) {
//             		System.out.println((sigma.get(v).doubleValue()/sigma.get(w).doubleValue())+" "+( (1.0/dist.get(w)) + delta.get(w)));
//            		System.out.println(w+"("+delta.get(w)+") on "+v+"  zysk delte: "+ (sigma.get(v).doubleValue()/sigma.get(w).doubleValue())*( (1.0/dist.get(w)) + delta.get(w)));
//             	}
            }
            if (!w.equals(source)) {
            	centralities.put(w, centralities.get(w)+(delta.get(w) + ((double)(2-dist.get(w)))/dist.get(w))/2.0);
            }
        }
    }
    

}
